/*
 * Copyright 2012-2019 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springframework.boot.web.embedded.tomcat;

import java.io.File;
import java.nio.charset.Charset;

import org.apache.catalina.Context;
import org.apache.catalina.Engine;
import org.apache.catalina.Valve;
import org.apache.catalina.connector.Connector;

import org.springframework.boot.web.server.ConfigurableWebServerFactory;

/**
 * 用于Tomcat特定功能的 {@link ConfigurableWebServerFactory} 接口。
 *
 * @author Brian Clozel
 * @since 2.0.0
 * @see TomcatServletWebServerFactory
 * @see TomcatReactiveWebServerFactory
 */
public interface ConfigurableTomcatWebServerFactory extends ConfigurableWebServerFactory {

	/**
	 * 设置Tomcat的基础目录。如果未指定，则使用临时目录。
	 * @param baseDirectory Tomcat基础目录
	 */
	void setBaseDirectory(File baseDirectory);

	/**
	 * 设置后台处理器的延迟时间，单位为秒。
	 * @param delay 延迟时间（秒）
	 */
	void setBackgroundProcessorDelay(int delay);

	/**
	 * 添加应应用于Tomcat {@link Engine} 的 {@link Valve}。
	 * @param engineValves 要添加的阀门
	 */
	void addEngineValves(Valve... engineValves);

	/**
	 * 添加应应用于Tomcat {@link Connector} 的 {@link TomcatConnectorCustomizer}。
	 * @param tomcatConnectorCustomizers 要添加的定制器
	 */
	void addConnectorCustomizers(TomcatConnectorCustomizer... tomcatConnectorCustomizers);

	/**
	 * 添加应应用于Tomcat {@link Context} 的 {@link TomcatContextCustomizer}。
	 * @param tomcatContextCustomizers 要添加的定制器
	 */
	void addContextCustomizers(TomcatContextCustomizer... tomcatContextCustomizers);

	/**
	 * 添加应应用于Tomcat {@link Connector} 的 {@link TomcatProtocolHandlerCustomizer}。
	 * @param tomcatProtocolHandlerCustomizers 要添加的定制器
	 * @since 2.2.0
	 */
	void addProtocolHandlerCustomizers(TomcatProtocolHandlerCustomizer<?>... tomcatProtocolHandlerCustomizers);

	/**
	 * 设置用于URL解码的字符编码。如果未指定，则使用'UTF-8'。
	 * @param uriEncoding 要设置的URI编码
	 */
	void setUriEncoding(Charset uriEncoding);

}
